Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

console-table-printer

Package Overview
Dependencies
Maintainers
1
Versions
266
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

console-table-printer

Printing pretty tables on console log

  • 2.12.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created

What is console-table-printer?

The console-table-printer npm package is a utility for printing tables to the console in a visually appealing way. It is useful for developers who need to display tabular data in a readable format directly in the terminal.

What are console-table-printer's main functionalities?

Basic Table Printing

This feature allows you to print a basic table with rows of data. The code sample demonstrates how to create a table, add rows to it, and print it to the console.

const { Table } = require('console-table-printer');
const p = new Table();
p.addRow({ index: 1, name: 'John', age: 25 });
p.addRow({ index: 2, name: 'Jane', age: 30 });
p.printTable();

Custom Column Formatting

This feature allows you to customize the alignment of columns in the table. The code sample shows how to set different alignments for each column.

const { Table } = require('console-table-printer');
const p = new Table({
  columns: [
    { name: 'index', alignment: 'left' },
    { name: 'name', alignment: 'center' },
    { name: 'age', alignment: 'right' }
  ]
});
p.addRow({ index: 1, name: 'John', age: 25 });
p.addRow({ index: 2, name: 'Jane', age: 30 });
p.printTable();

Colorful Table Output

This feature allows you to add colors to the table output for better visual distinction. The code sample demonstrates how to set different colors for each column.

const { Table } = require('console-table-printer');
const p = new Table({
  columns: [
    { name: 'index', color: 'red' },
    { name: 'name', color: 'green' },
    { name: 'age', color: 'blue' }
  ]
});
p.addRow({ index: 1, name: 'John', age: 25 });
p.addRow({ index: 2, name: 'Jane', age: 30 });
p.printTable();

Other packages similar to console-table-printer

Keywords

FAQs

Package last updated on 20 Jun 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc